/*
 * Copyright (C) 2012 Jakub Narloch (jmnarloch@gmail.com), All Rights Reserved.
 */

function defaultAjaxErrorHandler(jqXHR, status, error) {
    alert(error);
}

function displayTable(columnNames, data, target) {

    var cols = [];
    jQuery.each(columnNames, function(index, element) {
        cols.push("<td>" + element + "</td>");
    });

    var rows = [];
    jQuery.each(data, function (index, element) {

        rows.push("<tr><td>" + element.name + "</td></tr>");
    });

    var content = jQuery("<thead/>",
        { html: "<tr>" + cols.join("") + "</tr>" }
    ).outerHTML + rows.join("");

    jQuery(target).empty();
    jQuery("<table/>", { html: content}).appendTo(target);
}

